package com.lhkj.ct.platform.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.lhkj.ct.base.annntation.Log;
import com.lhkj.ct.base.enums.ActionType;
import com.lhkj.ct.base.model.dto.PageQuery;
import com.lhkj.ct.base.model.ro.ActionResult;
import com.lhkj.ct.meta.modules.psychology.model.entity.TblScaleReport;
import com.lhkj.ct.meta.modules.psychology.model.vo.PersonalReportInfo;
import com.lhkj.ct.meta.modules.psychology.service.ScaleReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *      测验报告
 * </p>
 *
 * @author jobob
 * @since 2023-10-16
 */
@RestController
@RequestMapping("api/my/psy/report")
@Api(tags = {"2.测验报告"})
public class MyPsyReportController {

    @Resource
    private ScaleReportService reportService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "报告列表")
    @GetMapping("list")
    public ActionResult<IPage<TblScaleReport>> selectPatUnitPage(TblScaleReport report, PageQuery pageQuery) {
        return ActionResult.success(reportService.selectReportPageByPatient(report, pageQuery));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "查看报告")
    @GetMapping("{rId}/get")
    public ActionResult<PersonalReportInfo> selectPatUnitPage(@PathVariable String rId) {
        return ActionResult.success(reportService.getReportInfo(rId));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "导出pdf", notes = "仅支持单个")
    @PutMapping(value = "{rId}/exportPdf")
    @Log(title = "导出测验报告", actionType = ActionType.EXPORT, isSaveResponseData = false)
    public void exportPdf(@PathVariable String rId) {
        reportService.exportPdf(rId);
    }
}
